package com.wrk._1_语法._04_循环._01_单循环;

import java.util.Scanner;

public class _005_是否为完数 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个数,判断是否为完数:");
        //定义变量
        int perfectNumber = scanner.nextInt();
        int sum =0;
        //循环+判断
        for (int n=1;n<perfectNumber;n++){
            if (perfectNumber%n==0){
                sum=sum+n;
            }
        }
        if (sum==perfectNumber){
            System.out.println("是完数");
        }
        else {
            System.out.println("不是完数");
        }
        scanner.close();
    }
}

